<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // Math.random() 0-1的随机数
        // console.log(Math.random() * 100);

        // console.log(Math.random(1, 100));

        // console.log(Math.floor(Math.random() * 11));      // 取值0-10的数

        let arr = ['pink', 'red', 'blue', '张三', '李四', '王五']
        // let random = Math.floor(Math.random() * 6)
        let random = Math.floor(Math.random() * arr.length)
        // console.log(arr[random]);

        // 生成5-10的随机数
        let fiveToTen = Math.floor(Math.random() * (5 + 1)) + 5
        // console.log(fiveToTen);

        // 生成n-m之间的随机数 左闭右闭
        // let nToM = Math.floor(Math.random() * (m - n + 1)) + n

        function getRandom(n = 0, m = 0) {
            return Math.floor(Math.random() * (m - n + 1)) + n
        }
        let num = getRandom(3, 6)
        console.log(num);

    </script>
</body>

</html>